package com.itheima.map.mapdemo;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MyMap2 {
    public static void main(String[] args) {
        Map<String ,String > map = new HashMap<>();
        map.put("1号丈夫","1号夫妻");
        map.put("2号丈夫","2号夫妻");
        map.put("3号丈夫","3号夫妻");
        map.put("4号丈夫","4号夫妻");
        map.put("5号丈夫","5号夫妻");

        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            System.out.println(entry.getKey() + "-----" + entry.getValue());
        }

        System.out.println("=====================");

        Set<String> set = map.keySet();
        for (String key : set) {
            String value = map.get(key);
            System.out.println(key + "-----" + value);
        }

        System.out.println("=====================");

        map.forEach((key,value) -> System.out.println(key + "-----" + value));
    }
}
